fix(typescript): build Router event markets as MarketList - #2111
Open
VaggelisGian wants to merge 1 commit into
Open
fix(typescript): build Router event markets as MarketList#2111VaggelisGian wants to merge 1 commit into
VaggelisGian wants to merge 1 commit into
Conversation
Router's local convertEvent() returned markets as a plain array, but UnifiedEvent.markets is typed MarketList and callers rely on its .match() helper, so results from fetchEventMatches and fetchMatchedEventClusters threw TypeError on .match(). Build the array with MarketList.from(...) exactly like the canonical converter in client.ts does. Fixes pmxt-dev#2074
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2074
What was broken
Router's local convertEvent() in sdks/typescript/pmxt/router.ts built markets as a plain array, while UnifiedEvent.markets is declared as MarketList (an Array subclass with a .match(query) helper). Any caller doing result.event.markets.match(...) or result.markets.match(...) on data from Router.fetchEventMatches or Router.fetchMatchedEventClusters got TypeError: ...match is not a function, despite the type system promising MarketList. Python has no equivalent bug because router.py reuses the single _convert_event from client.py.
What changed
router.ts now builds the markets array with MarketList.from((raw.markets || []).map(convertMarket)) as MarketList, exactly matching the canonical converter in client.ts. This covers both call sites that use the local converter (fetchEventMatches and fetchMatchedEventClusters). No other behavior changes; the per-venue converters in client.ts are untouched.
Tests
Added sdks/typescript/tests/router-event-markets.test.ts following the existing router-sql-orderbook.test.ts fetch-spy pattern:
Both tests fail without the fix (TypeError / not instanceof MarketList) and pass with it.
Verification